#ifndef SLEEP_API_H
#define SLEEP_API_H

#include "common.h"
#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
  ENUM_SLEEP_STAGING_TYPE_NONE = 0,
  ENUM_SLEEP_STAGING_TYPE_WAKE,
  ENUM_SLEEP_STAGING_TYPE_NREM1,
  ENUM_SLEEP_STAGING_TYPE_NREM3,
  ENUM_SLEEP_STAGING_TYPE_REM,
  ENUM_SLEEP_STAGING_TYPE_NAP
} sleep_types_t;

typedef struct _each_activity {
  sleep_types_t type;
  uint64_t begin;
  uint64_t end;
} each_activity_t;

typedef struct _act_smy {
  uint64_t begin;
  uint64_t end;
  double avg_hr;
  uint32_t cnt_acts;
  each_activity_t *act_list;
} activity_summary_t;

// 统计结果入口
typedef struct _slp_root {
  double avg_hr;
  double resting_hr;
  uint32_t count;
  activity_summary_t *summaries;
} sleep_root;

/*
设置采样周期
@param minutes: 单位分钟
 */
EXPORT void set_smp_interval(uint8_t minutes);
// 获取采样周期
EXPORT uint8_t get_smp_interval(void);
/*
计算睡眠周期
@param hr_list: 睡眠数据列表
@param len: 个数
 */
EXPORT void v3_calc(smp_hr_t *hr_list, size_t len, sleep_root **root);
/*
释放睡眠统计结果内存
 */
EXPORT void free_activities(sleep_root *ba);

#ifdef __cplusplus
}
#endif

#endif